--------------------------------------------------
-- Level code
-- Created 6:15 2021-3-9
--------------------------------------------------

-- Run code on level start
function onStart()
    --Your code here
end

-- Run code every frame (~1/65 second)
-- (code will be executed before game logic will be processed)
function onTick()
    for key, NPC in pairs(NPC.get(16,-1)) do
        NPC.id = 97
        NPC.speedY = -3.5
        triggerEvent("Silence Boss")
    end
end

-- Run code when internal event of the SMBX Engine has been triggered
-- eventName - name of triggered event
function onEvent(eventName)
    --Your code here
end

function onNPCKill(eventObj, npcObj, npcKillReason) 
	if (npcObj.id == 97 and npcKillReason == 9) and not globalsave.SaveTheTown then
		globalsave.SaveTheTown = true
		Text.showMessageBox("The town has been restored!")
	end
end